<template>
  <el-table
    :data="authList"
    row-key="name"
    style="width: 100%"
    border
    stripe
    :tree-props="{ children: 'subMenus', hasChildren: 'hasChildren' }"
  >
    <el-table-column prop="name" label="权限名称"> </el-table-column>
    <el-table-column prop="path" label="路径"> </el-table-column>
    <el-table-column prop="id" label="权限等级">
      <template slot-scope="scope">
        <el-tag v-if="!scope.row.path">一级</el-tag>
        <el-tag v-if="scope.row.path" type="success">二级</el-tag>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
// import authList from "./authdata";
export default {
  data() {
    return {
      authList: [],
    };
  },
  created() {
    this.getAuthList();
    // g_menuList.forEach((item) => {
    //   this.menuList.push({ id: item.id, name: item.name });
    //   if (item.subMenus) {
    //     item.subMenus.forEach((v) => {
    //       this.menuList.push({ id: v.id, name: v.name, path: v.path });
    //     });
    //   }
    // });
    // console.log(this.menuList);
  },
  methods: {
    /**
     * 获取权限列表
     */
    async getAuthList() {
      // let response = await this.$http.Get("/api/Menus");
      let response = await fetch("https://localhost:5001/api/Menus");
      if (response.ok) {
        this.authList = response.data;
      }
    },
  },
};
</script>

<style></style>
